import * as echarts from 'echarts';
import { useEffect, useRef } from 'react';


const BartChart = ({ title }) => {

    const chartRef = useRef()

    useEffect(() => {
        const chartDom = chartRef.current
        const myChart = echarts.init(chartDom);
        const option = {
            title: {
                text: title
            },
            xAxis: {
                type: 'category',
                data: ['Vue', 'React', 'Angular']
            },
            yAxis: {
                type: 'value'
            },
            series: [
                {
                    data: [10, 40, 70],
                    type: 'bar'
                }
            ]
        };

        option && myChart.setOption(option);
    }, [title])

    return <div ref={chartRef} style={{ height: '400px', width: '500px' }} />
}

export default BartChart;